﻿using Orleans;
using Pay.Configuration;
using Pay.Model.Dto;
using Pay.Model.Interfaces;
using Pay.Service.user;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;

namespace Pay.Api.Controllers.Admin
{
    [RoutePrefix("api/user")]
    public class UserController : BaseApiController
    {
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [AllowAnonymous]
        [Route("Login"), HttpPost]
        public async Task<LoginOutPut> Login([FromBody] LoginOutPut input)
        {
            var service = GrainClient.GrainFactory.GetGrain<IUserSerive>("0");
            return await service.UserLogin(input);
        }
        /// <summary>
        /// 加载用户模块
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("Menu")]
        public async Task<List<Menu>> GetMenu()
        {
            var service = GrainClient.GrainFactory.GetGrain<IUserSerive>("0");

            return await service.GetAllMeun(CurrentUser.Id);
        }
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        //[Route("List"),HttpGet]
        //public async Task<IPagedOutput<UserInfoDto>> GetUserList([FromUri]QueryDto query)
        //{
        //    var service = GrainClient.GrainFactory.GetGrain<IUserSerive>("0");
        //    return await service.GetUserPage(CurrentUser.Tid, query.SearchWord, query.timeBegin, query.timeEnd, (query.PageIndex-1)*query.PageSize, query.PageSize);
        //}
        ///// <summary>
        ///// 新增用户
        ///// </summary>
        ///// <param name="model"></param>
        ///// <returns></returns>
        //[Route("AddUser"),HttpPost]
        //public async Task<bool> AddUser([FromBody] UserInfoDto model)
        //{
        //     var service = GrainClient.GrainFactory.GetGrain<IUserSerive>("0");
        //     return  await service.Add(model);
        //}
    }
}
